package Client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectInputStream;
//import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

public class ChatterClient 
{
	public static void main(String[] args) throws Exception
	{
		
		InetAddress host;
		try {
			host = InetAddress.getLocalHost();
			
			Socket socket = new Socket(host.getHostName(), 1234);
			
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		    String textLine = input.readLine();
			
			ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
			oos.writeObject(textLine);	
			
			ObjectInputStream is;
			try {
				is = new ObjectInputStream(socket.getInputStream());
				String msg;
				try {
					msg = (String) is.readObject();
					System.out.println(msg);
				} catch (ClassNotFoundException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			
			
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
	}
}
